
let write_obj tritab =
  let stream = open_out "map.obj" in
    begin
    output_string stream "# VirgoTerris\n#";
    output_string stream "\ng map\n\n";
    end;

    let l = Array.length tritab in
      begin
	for i = 0 to l-1 do
	  output_string stream
	    ("v "^string_of_float tritab.(i).Types.p1.Types.x^
	       " "^string_of_float tritab.(i).Types.p1.Types.y^
	       " "^string_of_float tritab.(i).Types.p1.Types.z^"\n"^
	       "v "^string_of_float tritab.(i).Types.p2.Types.x^
	       " "^string_of_float tritab.(i).Types.p2.Types.y^
	       " "^string_of_float tritab.(i).Types.p2.Types.z^"\n"^
	       "v "^string_of_float tritab.(i).Types.p3.Types.x^
	       " "^string_of_float tritab.(i).Types.p3.Types.y^
	       " "^string_of_float tritab.(i).Types.p3.Types.z^"\n");
	done;
	output_string stream "\n";
	for i = 0 to l-1 do
	  output_string stream
	    ("vn "^string_of_float tritab.(i).Types.norm.Types.x^
	       " "^string_of_float tritab.(i).Types.norm.Types.y^
	       " "^string_of_float tritab.(i).Types.norm.Types.z^"\n");
	done;
	output_string stream "\n";
	for i = 3 to l-1 do
	  output_string stream
	    ("f "^string_of_int (3*i-2)^"//"^string_of_int (i+1)^" "^
	       string_of_int (3*i-1)^"//"^string_of_int (i+1)^" "^
	       string_of_int (3*i)^"//"^string_of_int (i+1)^"\n");
	done;
      end;
      close_out stream


